

package com.hazelcast.map.impl;

import com.hazelcast.internal.services.ClientAwareService;
import com.hazelcast.map.impl.querycache.QueryCacheContext;
import com.hazelcast.map.impl.querycache.publisher.PublisherContext;

import java.util.UUID;

/**
 * Defines {@link ClientAwareService} behavior of map service.
 * This service is used to clean unneeded resources.
 *
 * @see ClientAwareService
 */
class MapClientAwareService implements ClientAwareService {

    private final MapServiceContext mapServiceContext;

    MapClientAwareService(MapServiceContext mapServiceContext) {
        this.mapServiceContext = mapServiceContext;
    }

    @Override
    public void clientDisconnected(UUID clientUuid) {
        QueryCacheContext queryCacheContext = mapServiceContext.getQueryCacheContext();
        PublisherContext publisherContext = queryCacheContext.getPublisherContext();
        publisherContext.handleDisconnectedSubscriber(clientUuid);
    }
}
